import { DataTypes } from "sequelize"

import seq from '../db/seq.js'
import User from '../user.model.js'

const UserInfo = seq.define('sys_user_info', {
  sex: {
    type: DataTypes.CHAR(1),
    allowNull: false,
    defaultValue: '0',
    comment: '性别（0男 1女）',
  },
  age: {
    type: DataTypes.INTEGER,
    comment: '年龄',
  },
  height: {
    type: DataTypes.INTEGER,
    comment: '身高',
  },
  weight: {
    type: DataTypes.FLOAT(5, 2),
    comment: '体重',
  },
  constellation: {
    type: DataTypes.CHAR(3),
    comment: '星座',
  },
  birthday: {
    type: DataTypes.DATEONLY,
    comment: '生日',
  },
  marriage: {
    type: DataTypes.CHAR(1),
    allowNull: false,
    defaultValue: '0',
    comment: '婚否（0未婚 1已婚）',
  },
  disposition: {
    type: DataTypes.STRING,
    comment: '性格',
  },
  hobby: {
    type: DataTypes.STRING,
    comment: '爱好',
  },
  blood_type: {
    type: DataTypes.CHAR(3),
    comment: '血型',
  },
  nation: {
    type: DataTypes.STRING(20),
    comment: '民族',
  },
  education: {
    type: DataTypes.STRING(100),
    comment: '学历',
  },
  job: {
    type: DataTypes.STRING(100),
    comment: '职业',
  },
  like_game: {
    type: DataTypes.STRING,
    comment: '爱玩的游戏',
  },
  phone: {
    type: DataTypes.CHAR(11),
    unique: true,
    comment: '手机号码',
  },
  qq: {
    type: DataTypes.CHAR(11),
    unique: true,
    comment: 'QQ',
  },
  wechat: {
    type: DataTypes.CHAR(28),
    unique: true,
    comment: '微信',
  },
  user_id: {
    type: DataTypes.UUID,
    defaultValue: DataTypes.UUIDV4,
    allowNull: false,
    unique: true,
    comment: '用户ID',
    // 设置外键约束
    references: {
      model: User,
      key: 'id',
    }
  },
  remark: {
    type: DataTypes.STRING,
    comment: '备注',
  },
}, {
  freezeTableName: true
})

// UserInfo.sync({ force: true })

export default UserInfo